//
//  FindViewController.m
//  HonlivApp
//
//  Created by admin on 2017/6/23.
//  Copyright © 2017年 honliv. All rights reserved.
//

#import "FindViewController.h"
#import "FindViewModel.h"
#import "CommonStaticCell.h"
#import "CarsTBViewController.h"
#import "RemindNewsViewController.h"
#import "BirthdayView.h"
#import "RecommendNewsViewController.h"

@interface FindViewController ()
@property (nonatomic,strong) FindViewModel *viewModel;
@end

@implementation FindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"发现";
}

-(void)getDatasArray{
    [self getDatasArray:^(GetDatas handler) {
        _viewModel = [[FindViewModel alloc] init];
        [_viewModel getDatasArraySuccess:^{
            handler(_viewModel.datasArray);
        }];
    }];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:{
            CarsTBViewController *carsTB = [[CarsTBViewController alloc] init];
            [self pushViewControllerTo:carsTB];
        }
            break;
        case 1:{
            RemindNewsViewController *remindV = [[RemindNewsViewController alloc] init];
            [self pushViewControllerTo:remindV];
        }
            break;
        case 2:{
            BirthdayView *birthdayV = [[BirthdayView alloc] initWithFrame:CGRectMake(0, kScreenH, kScreenW, kScreenH)];
            [self.view addSubview:birthdayV];
            [birthdayV hideView:^{
                [birthdayV removeFromSuperview];
            }];
            [BirthdayView animateWithDuration:0.3 animations:^{
                birthdayV.frame = CGRectMake(0, 0, kScreenW, kScreenH - 64);
            }];
        }
            break;
        case 3:{
            RecommendNewsViewController *recommendV = [[RecommendNewsViewController alloc] init];
            [self pushViewControllerTo:recommendV];
        }
            break;
        default:
            break;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CommonStaticCell *cell = [CommonStaticCell cellWithTableView:tableView];
    cell.dic = _viewModel.datasArray[indexPath.section][indexPath.row];
    return cell;
}

@end
